<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="admin/common/common_css :: commonHeader('编辑机构')">
</head>
<body>
<article class="page-container">
    <form class="form form-horizontal" id="form-org-edit">
        <input type="hidden" name="orgId" th:value="${editOrg.orgId }" />
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>机构名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" placeholder="机构名称（必填）" th:value="${editOrg.orgName }" id="orgName" name="orgName" maxlength="50" />
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>机构地址：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" placeholder="机构地址（必填）" th:value="${editOrg.orgAddress }" name="orgAddress" id="orgAddress" maxlength="255" />
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">机构别名：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" placeholder="机构别名" th:value="${editOrg.orgAliasName }" id="orgAliasName" name="orgAliasName" maxLength="50" />
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">机构电话：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" placeholder="机构电话" th:value="${editOrg.orgPhone }" name="orgPhone" id="orgPhone" maxlength="50" />
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">机构传真：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" placeholder="机构传真" th:value="${editOrg.orgFax }" name="orgFax" id="orgFax" maxlength="50" />
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">机构网址：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" placeholder="机构网址（http://）" th:value="${editOrg.orgWebsite }" name="orgWebsite" id="orgWebsite" maxlength="255" />
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">管理名称：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" placeholder="管理人员名称" th:value="${editOrg.orgManagerName }" name="orgManagerName" id="orgManagerName" maxlength="50" />
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">管理电话：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" placeholder="管理人员电话" th:value="${editOrg.orgManagerPhone }" name="orgManagerPhone" id="orgManagerPhone" maxlength="50" />
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">机构说明：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <textarea name="orgDesc" maxlength="200" class="textarea"  placeholder="机构说明...200个字符以内" onKeyUp="javascript:textareaLength(this);">
                   <th:block th:text="${editOrg.orgDesc }"></th:block>
                </textarea>
                <p class="textarea-numberbar"><em class="textarea-length"><span id="textareaLengthSpan">0</span></em>/200</p>
            </div>
        </div>
        <div class="row cl">
            <div style="text-align: center;">
                <button class="btn btn-primary radius" type="submit">
                    <i class="Hui-iconfont">&#xe632;</i> 保存
                </button>
                &nbsp;&nbsp;
                <button onClick="layer_close();" class="btn btn-default radius" type="button">
                    &nbsp;&nbsp;取消&nbsp;&nbsp;
                </button>
            </div>
        </div>
    </form>
</article>
<div th:include="admin/common/common_js :: onLoadJS"></div>
<script type="text/javascript" th:src="@{/js/admin.ui/lib/jquery.validation/1.14.0/jquery.validate.js}"></script>
<script type="text/javascript" th:src="@{/js/admin.ui/lib/jquery.validation/1.14.0/validate-methods.js}"></script>
<script type="text/javascript" th:src="@{/js/admin.ui/lib/jquery.validation/1.14.0/messages_zh.js}"></script>
<script type="text/javascript">
    $(function(){
        $("#form-org-edit").validate({
            rules:{
                orgName:{required:true, minlength:2, maxlength:50},
                orgAddress:{required:true, minlength:4, maxlength:255},
                orgAliasName:{required:false, minlength:2, maxlength:50},
                orgPhone:{required:false, minlength:6, maxlength:255},
                orgFax:{required:false, minlength:6, maxlength:50},
                orgWebsite:{required:false, minlength:6, maxlength:255},
                orgManagerName:{required:false, minlength:2, maxlength:50},
                orgManagerPhone:{required:false, minlength:6, maxlength:50}
            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                send(
                    '/pestdiagnosis/sys/org/edit',
                    $('#form-org-edit').serialize(),
                    function (data) {
                        if(data.result == 0) {
                            layer.msg(data.message, {icon: 1,time: 1500}, function() {
                                window.parent.location.href =  "/pestdiagnosis/sys/org/list";
                            });
                        } else {
                            layer.msg(data.message, {icon: 5,time: 1500});
                            $('#orgName').focus();
                        }
                    },
                    function (res) {

                    }

                );

            }
        });
    });
    // 计算文本域字符长度
    function textareaLength(obj) {
        $('#textareaLengthSpan').text($(obj).val().length);
    }
</script>
</body>
</html>